package com.leyou.item.api;

import com.leyou.common.pojo.PageResult;
import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.SpuDetail;
import com.leyou.item.dto.CartDTO;
import com.leyou.item.vo.SpuDTO;
import com.leyou.item.vo.SpuVO;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: Rose
 * @Date: 2021/4/3 10:40
 * @description ${description}
 * @version: 1.0.0
 */
public interface GoodsApi {


    /**
     * 根据spu 的id 查询详情detail
     *
     * @param spuId
     * @return
     */
    @GetMapping("/spu/detail/{id}")
    SpuDetail queryDetailByid(@PathVariable("id") Long spuId);

    /**
     * 根据spu 查询下面的所有 sku
     *
     * @param id
     * @return
     */
    @GetMapping("/sku/list")
    List<Sku> querySkuBySpuId(@RequestParam("id") Long id) throws Exception;


    /**
     * 根据spu的id 查询spu
     */
    @GetMapping("/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id") Long id);

    /**
     * 分页查询spu 信息
     *
     * @param page
     * @param rows
     * @param saleable
     * @param key
     * @return
     */
    @GetMapping("/spu/page")
    PageResult<SpuVO> querySpuByPaeg(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", required = false) Boolean saleable,
            @RequestParam(value = "key", required = false) String key

    );

    /**
     * 根据spu 的id集合查询下面的所有 sku
     *
     * @param ids
     * @return
     */
    @GetMapping("/sku/list/ids")
    List<Sku> querySkuBySpuIds(@RequestParam("ids") List<Long> ids) throws Exception;

    /**
     * 减少库存
     *
     * @param carts
     */
    @PostMapping("/stock/decrease")
    void decreaseStock(@RequestBody List<CartDTO> carts);
}
